package stack.era.presentation.main_menu;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;

public class MainMenuButton extends JButton implements MouseListener {

	private static final long serialVersionUID = 288929359634777582L;

	private static final Dimension BUTTON_SIZE = new Dimension(400, 200);

	/**
	 * Setup the look and feel of a menu button object.
	 * 
	 * @param title
	 */
	public MainMenuButton(String title) {
		super(" " + title + " ");

		this.setSize(BUTTON_SIZE);
		this.setBackground(Color.WHITE);
		this.setForeground(Color.BLACK);
		this.setOpaque(false);
		this
				.setBorder(BorderFactory.createMatteBorder(5, 2, 2, 2,
						Color.BLACK));

		this.addMouseListener(this);
	}

	@Override
	public void paint(Graphics g) {
		Graphics2D g2 = (Graphics2D) g.create();
		g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
				0.5f));
		g2.setColor(this.getBackground());
		g2.fillRect(0, 0, this.getWidth(), this.getHeight());
		g2.dispose();
		super.paint(g);
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		if (this.isEnabled()) {
			this.setBackground(Color.BLUE);
			this.setForeground(Color.WHITE);
			this.repaint();
			this.requestFocus();
		}
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		this.setBackground(Color.WHITE);
		this.setForeground(Color.BLACK);
		this.repaint();
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

}
